concatMap

inline fun <ERR, A, B> ValidatedNel<ERR, A>.concatMap(f: (A) -> ValidatedNel<ERR, B>): ValidatedNel<ERR, B>(source)

The Validated type doesn't natively support flatMap because of the monad laws that it breaks. But this is what flatMap would do if it were allowed. We've called it concatMap because the Kotlin compiler will want to wire in the Monad flatMap extension instead and confusion reigns.

eg:

val maybeParty: ValidatedNel = ...

val result : ValidatedNel = maybeParty.concatMap { party -> validateCashTag(party.responder.cashTag) }

result == ValidNel("$jackjack")